﻿@{
    Layout = null;
    var moduleModel = ViewBag.moduleModel as NB.MGJ.Model.Origins_Module;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>上海诺标</title>


    @*<link href="~/Content/Bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/Scripts/miniui/themes/default/miniui.css" rel="stylesheet" />
    <link href="~/Content/Scripts/miniui/themes/icons.css" rel="stylesheet" />
    <link href="~/Content/css/layout-default-latest.css" rel="stylesheet" />*@

    <link href="~/Content/CommonCss/BootStrap/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/CommonCss/miniui/themes/default/miniui.css" rel="stylesheet" />
    <link href="~/Content/CommonCss/miniui/themes/icons.css" rel="stylesheet" />


    <style>
        table td
        {
            border: 1px #b7a0a0 solid;
        }

        .jumbotron img
        {
            width: 100%;
            height: auto;
        }

        .jumbotron video
        {
            width: 100%;
            height: 280px;
        }
    </style>

</head>
<body>
    <div id="moduleList">





    </div>
</body>
</html>


@*<script src="~/Content/Scripts/jquery.min.js"></script>
<script src="~/Content/Bootstrap/bootstrap.min.js"></script>
<script src="~/Content/Scripts/miniui/miniui.js"></script>
<script src="~/Content/Scripts/Tools/swfupload/swfupload.js"></script>*@


@*<script src="~/Scripts/jquery.js"></script>*@
<script src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="~/Content/CommonCss/BootStrap/bootstrap.min.js"></script>
<script src="~/Content/CommonCss/miniui/miniui.js"></script>
<script src="~/Content/CommonCss/miniui/swfupload/swfupload.js"></script>



<script>


    $(document).ready(function () {
        setModule();
    });

    function setModule() {
        $.ajax({
            type: "POST",
            dataType: 'json',
            url: "/MaterialPreview/" + "GetModuleById?moduleId=" +@moduleModel.ModuleId +"",
            cache: false,
            success: function (data) {
                if (data == 0) {
                    window.location.href = "/error/MobileOptionError";
                    return;
                }
                data = mini.decode(data);
                append(data);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                $.L.msgError(jqXHR.responseText);
            }
        });
    }


    function append(module) {
        var html = "";
        var moduleEntity = module;
        //图文
        if (moduleEntity.ModuleType == 0) {
            html = [' <div id=' + moduleEntity.ModuleId + ' class="jumbotron padding0">',
  '                <p class="jtitle">' + moduleEntity.Title + '</p>',
  '                <img onerror="this.style.display=\'none\'" style="width:100%;height:150px;" src=' + moduleEntity.Picture + ' />',
  '                <p>' + moduleEntity.ModuleContent + '</p>',

  '            </div>'].join("");
            $("#moduleList").append(html);
        }
        //网址导航
        if (moduleEntity.ModuleType == 1) {
            CreateNavHtml(moduleEntity.ModuleId);
        }
    }





    function CreateNavHtml(moduleId) {
        $.ajax({
            url: "",
            dataType: 'json',
            type: "POST",
            success: function (data) {
            }
        });
        var rowId = "row" + moduleId;
        var wrapHtml = ['    <div id=' + moduleId + ' class="jumbotron">',
                   '<div class="row-fluid" id=' + rowId + '>',
                   '</div>',
                   '</div>'
        ].join("");

        $("#moduleList").append(wrapHtml);
        var html = "";
        $.ajax({
            type: "POST",
            dataType: 'json',
            url: "/MaterialPreview/" + "GetNavListByModuleId?moduleId=" + moduleId,
            cache: false,
            success: function (data) {

                var navList = mini.decode(data);
                for (var i = 0; i < navList.length; i++) {
                    var navEntity = navList[i];

                    if (navEntity.LinkGoto == "") {
                        navEntity.LinkGoto = "unknow"
                    }
                    if (navEntity.PageGoto == "") {
                        navEntity.PageGoto = "unknow";
                    }
                    html += [
 '        <div class="span3" name="navLink" action=' + navEntity.Action + ' link=' + navEntity.LinkGoto + ' materialGoto=' + navEntity.MaterialGoto + ' pageGoto=' + navEntity.PageGoto + ' id=' + navEntity.NavId + '>',
 '            <a class="mini-button">',
 '                <img id="ico" src="' + navEntity.Ico + '" />',
 '            </a>',
 '        </div> ',
                    ].join("");
                }
                $("#" + rowId).append(html);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                $.L.msgError(jqXHR.responseText);
            }
        });
    }


    $(document).off("click", "[name='navLink']").on("click", "[name='navLink']", function () {

        var link = $(this).attr("Link");
        var action = $(this).attr("action");
        var host = window.location.host;
        var materialGoto = $(this).attr("materialGoto");
        var pageGoto = $(this).attr("pageGoto")
        switch (action) {
            case "0":
                if (link == "unknow") {
                    return;
                } else {
                    window.open("http://" + link);
                }
                break;
            case "1":
                var url = host + "/MaterialPreview/ModuleIndex?moduleId=" + pageGoto;
                window.open("http://" + url);
                break;

            case "2":
                var url = host + "/MaterialPreview/Index?materialId=" + materialGoto;
                window.open("http://" + url);
                break;

            default:
                break;
        }
    });





</script>